#include "stdafx.h"
#include "wf_zoomin.h"


/**
 * Default constructor.
 *
 * @param direction In for zooming in, Out for zooming out.
 * @param axis Axis that are affected by the zoom (OnlyX, OnlyY or Both)
 */
WF_ZoomIn::WF_ZoomIn(PF_Container& container,
                                 PF_GraphicView& graphicView,
                                 LX_Define::ZoomDirection direction,
                                 LX_Define::Axis axis,
                                 const PF_Vector& center)
        :PF_ActionInterface("Zoom in", container, graphicView) {

    this->direction = direction;
    this->axis = axis;
    this->center = center;
}

QAction* WF_ZoomIn::createGUIAction(LX_Define::ActionType type, QObject* /*parent*/) {
    QAction* action;

    if (type==LX_Define::ActionZoomIn) {
		// tr("Zoom in")
		action = new QAction(tr("Zoom &In"), NULL);
#if QT_VERSION >= 0x040600
                action->setIcon(QIcon::fromTheme("zoom-in", QIcon(":/actions/zoomin.png")));
#else
                action->setIcon(QIcon(":/actions/zoomin.png"));
#endif
		action->setShortcut(QKeySequence::ZoomIn);
		//action->zetStatusTip(tr("Zooms in"));
    } else {
		// tr("Zoom Out")
		action = new QAction(tr("Zoom &Out"), NULL);
#if QT_VERSION >= 0x040600
                action->setIcon(QIcon::fromTheme("zoom-out", QIcon(":/actions/zoomout.png")));
#else
                action->setIcon(QIcon(":/actions/zoomout.png"));
#endif
                action->setShortcut(QKeySequence::ZoomOut);
		//action->zetStatusTip(tr("Zooms out"));
    }
    return action;
}


void WF_ZoomIn::init(int status) {
    PF_ActionInterface::init(status);
    trigger();
}

void WF_ZoomIn::trigger() {
    switch (axis) {
    case LX_Define::OnlyX:
        if (direction==LX_Define::In) {
            graphicView->zoomInX();
        } else {
            graphicView->zoomOutX();
        }
        break;

    case LX_Define::OnlyY:
        if (direction==LX_Define::In) {
            graphicView->zoomInY();
        } else {
            graphicView->zoomOutY();
        }
        break;

    case LX_Define::Both:
        if (direction==LX_Define::In) {
            graphicView->zoomIn(1.25, center);
        } else {
            graphicView->zoomOut(1.25, center);
        }
        break;
    }
    finish();
}




// EOF
